from meinheld import patch
import falcon
import logging

logging.disable()
# import falcon.asgi


patch.patch_all()


def fib3(n):
    if not isinstance(n, int) or n < 1:
        return None
    lib_seq = [1, 1]
    if n <= 2:
        return lib_seq[: n - 1]
    for i in range(n - 2):
        lib_seq.append(lib_seq[-1] + lib_seq[-2])
    return lib_seq


# class GetTestAsync:
#     async def on_get(self, req, resp):
#         a = fib3(5150)

#         resp.status = falcon.HTTP_200  # This is the default status
#         # resp.content_type = falcon.MEDIA_TEXT  # Default is JSON, so override
#         resp.text = bytes('{}'.format({"data": a[:200]}), 'utf-8')


class GetTest:
    def on_get(self, req, resp):
        a = fib3(5150)

        resp.status = falcon.HTTP_200  # This is the default status
        # resp.content_type = falcon.MEDIA_TEXT  # Default is JSON, so override
        resp.text = bytes('{}'.format({"data": a[:200]}), 'utf-8')

# app = falcon.asgi.App()
# get_test = GetTestAsync()
# app.add_route('/test_falcon', get_test)


app = application = falcon.App()
get_test = GetTest()
app.add_route('/test_falcon', get_test)
